#define RCC_MP_AHB4ENSETR *((volatile unsigned int*)0x50000A28)

typedef struct {
    volatile unsigned int MODER;
    volatile unsigned int OTYPER;
    volatile unsigned int OSPEEDR;
    volatile unsigned int PUPDR;
    volatile unsigned int IDR;
    volatile unsigned int ODR;
    volatile unsigned int BSRR;
    volatile unsigned int LCKR;
    volatile unsigned int AFRL;
    volatile unsigned int AFRH;
}gpio_t;


#define GPIOE ((gpio_t*)0x50006000)
#define GPIOF ((gpio_t*)0x50007000)

void delay(void);

void led_test(void)
{
    //GPIOE时钟使能
    RCC_MP_AHB4ENSETR |= (1UL << 4);
    //输出模式
    GPIOE->MODER &= ~(3UL << 20);
    GPIOE->MODER |= (1UL << 20);
    //推挽输出
    GPIOE->OTYPER &= ~(1UL << 10);
    //设置PE10引脚为High speed
    GPIOE->OSPEEDR &= ~(3UL << 20);
    GPIOE->OSPEEDR |= (1UL << 21);
    //设置无上下拉
    GPIOE->PUPDR &= ~(3UL << 20);


    /*LED2初始化，GPIOF10*/
    //GPIOF时钟使能
    RCC_MP_AHB4ENSETR |= (1UL << 5);
    //输出模式
    GPIOF->MODER &= ~(3UL << 20);
    GPIOF->MODER |= (1UL << 20);
    //推挽输出
    GPIOF->OTYPER &= ~(1UL << 10);
    //设置PF10引脚为High speed
    GPIOF->OSPEEDR &= ~(3UL << 20);
    GPIOF->OSPEEDR |= (2UL << 20);
    //设置无上下拉
    GPIOF->PUPDR &= ~(3UL << 20);

    // /*LED3初始化，GPIOE8*/
    //输出模式
    GPIOE->MODER &= ~(3UL << 16);
    GPIOE->MODER |= (1UL << 16);
    //推挽输出
    GPIOE->OTYPER &= ~(1UL << 8);
    //设置PF10引脚为High speed
    GPIOE->OSPEEDR &= ~(3UL << 16);
    GPIOE->OSPEEDR |= (1UL << 17);
    //设置无上下拉
    GPIOE->PUPDR &= ~(3UL << 16);


    while (1)
    {
        GPIOE->ODR |= (1UL << 10);
        delay();
        GPIOE->ODR &= ~(1UL << 10);
        delay();
        GPIOF->ODR |= (1UL << 10);
        delay();
        GPIOF->ODR &= ~(1UL << 10);
        delay();
        GPIOE->ODR |= (1UL << 8);
        delay();
        GPIOE->ODR &= ~(1UL << 8);
        delay();
    }
}

void delay(void)
{
    int i = 0x08000000;
	while(i--) ;
}